package cn.com.api.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.api.entity.ApiShoucang;
import cn.com.api.mapper.ApiConllectionMapper;
import cn.com.api.service.ApiConllectionService;

@Service
public class ApiConllectionServiceImpl implements ApiConllectionService {
	@Autowired
	private ApiConllectionMapper conllectMapper;

	@Override
	public void insert(String u_id, Integer shops_goods_id, Integer type) {
		ApiShoucang conllect = new ApiShoucang();
		conllect.setU_id(u_id);
		conllect.setShops_goods_id(shops_goods_id);
		conllect.setType(type);
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy/MM/dd HH:mm:ss");
		conllect.setSc_date(dateFormat.format(now));
		conllectMapper.insert(conllect);
	}

	@Override
	public void delconllet(@Param("sg_id") String sg_id) {
		conllectMapper.delconllect(sg_id);

	}

	@Override
	public List<ApiShoucang> conllet(Integer sid) {

		return conllectMapper.conllect(sid);
	}

}
